﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

namespace OpalisConsole.Views.User_Imaging
{
    public partial class UseUSMT : Page
    {
        public UseUSMT()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.Resources["Computer_ID"].Equals("Not Approved"))
            {
                this.NavigationService.Navigate(new System.Uri("/User_Imaging/Unauthorized", System.UriKind.Relative));
            }
            else
            {
                if (App.Current.Resources.Contains("DeveloperStatus"))
                {
                    if ((bool)App.Current.Resources["DeveloperStatus"]) { LinkUseUSMT.Visibility = System.Windows.Visibility.Visible; }
                    txtUseUSMTLandingHeader.Text = "User State Migration Tool Use";
                    txtUseUSMTChoice.Text = "As a developer you have the option of whether or not you would like USMT (User State Migration Tool) to run during your 'Fresh Start'";
                    txtUseUSMTDescriptionHeader.Text = "USMT is designed to copy and restore:";

                    txtUseUMSTMove1.Content = "    1.   All User Profiles";
                    txtUseUMSTMove2.Content = "    2.   Local Files outisde of redirected 'My Documents' Folder'";
                    txtUseUMSTMove3.Content = "    3.   Software Settings (i.e. some Outlook personalizations)";

                    copyData.Content = "Copy Data";
                    doNotCopyData.Content = "Do Not Copy Data";

                    DeveloperDataChoice.Visibility = System.Windows.Visibility.Visible;
                    if (App.Current.Resources.Contains("Data Choice"))
                    {
                        String dataChoice = App.Current.Resources["Data Choice"].ToString();
                        switch (dataChoice)
                        {
                            case "True":
                                copyData.IsChecked = true;
                                break;
                            case "False":
                                doNotCopyData.IsChecked = true;
                                break;
                            default:
                                copyData.IsChecked = true;
                                break;
                        }
                    }
                    else
                    {
                        copyData.IsChecked = true;
                    }
                }
                else
                {
                    this.NavigationService.Navigate(new System.Uri("/User_Imaging/LandingPage", System.UriKind.Relative));
                }
            }
        }
        private void doNotCopyData_Checked(object sender, RoutedEventArgs e)
        {
            if (Application.Current.Resources.Contains("Data Choice"))
            {
                Application.Current.Resources.Remove("Data Choice");
            }
            Application.Current.Resources.Add("Data Choice", "False");
        }

        private void copyData_Checked(object sender, RoutedEventArgs e)
        {
            if (Application.Current.Resources.Contains("Data Choice"))
            {
                Application.Current.Resources.Remove("Data Choice");
            }
            Application.Current.Resources.Add("Data Choice", "True");
        }

        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new System.Uri("/User_Imaging/Scheduling", System.UriKind.Relative));
        }

        private void btnPrevious_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new System.Uri("/User_Imaging/SoftwareValidation", System.UriKind.Relative));
        }
    }
}
